package com.galaxy.order.controller;

import com.galaxy.order.domain.UserFrequentProduct;
import com.galaxy.order.service.UserFrequentProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userFrequentProduct")
public class UserFrequentProductController {
    @Autowired
    private UserFrequentProductService userFrequentProductService;

    @PostMapping
    public UserFrequentProduct create(@RequestBody UserFrequentProduct userFrequentProduct) {
        userFrequentProductService.save(userFrequentProduct);
        return userFrequentProduct;
    }

    @PutMapping
    public UserFrequentProduct update(@RequestBody UserFrequentProduct userFrequentProduct) {
        userFrequentProductService.updateById(userFrequentProduct);
        return userFrequentProduct;
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return userFrequentProductService.removeById(id);
    }

    @GetMapping("/{id}")
    public UserFrequentProduct getById(@PathVariable Long id) {
        return userFrequentProductService.getById(id);
    }
}
